package com.dbgs.insurance.insuredperson.fragments;

import android.os.Bundle;
import android.support.v7.widget.AppCompatTextView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.dbgs.insurance.insuredperson.R;
import com.dbgs.insurance.insuredperson.activity.LoginActivity;
import com.dbgs.insurance.insuredperson.activity.SettingActivity;
import com.dbgs.insurance.insuredperson.activity.UserInfoActivity;
import com.dbgs.insurance.insuredperson.activity.order.OrderDetailActivity;
import com.dbgs.insurance.insuredperson.activity.register.RegisterActivity;
import com.hss.base.BaseFragment;
import com.leon.lib.settingview.LSettingItem;
import com.lz.commonlibrary.widget.CircleImageView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by Administrator on 2018/5/11.
 */

public class MyFragment extends BaseFragment {

    @BindView(R.id.civ_head)
    CircleImageView civHead;
    @BindView(R.id.user_name)
    AppCompatTextView userName;
    @BindView(R.id.user_phone)
    AppCompatTextView userPhone;
    @BindView(R.id.user_info)
    LSettingItem userInfo;
    @BindView(R.id.my_apply)
    LSettingItem myApply;
    @BindView(R.id.setting)
    LSettingItem setting;
    @BindView(R.id.customer_phone)
    LSettingItem customerPhone;
    @BindView(R.id.current_version)
    LSettingItem currentVersion;
    Unbinder unbinder;
    @BindView(R.id.btn_login)
    AppCompatTextView btnLogin;

    private View root_view;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        if (root_view == null) {
            root_view = inflater.inflate(R.layout.fragment_my, container,
                    false);
        }
        ViewGroup parent = (ViewGroup) root_view.getParent();
        if (parent != null) {
            parent.removeView(root_view);
        }

        unbinder = ButterKnife.bind(this, root_view);
        return root_view;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onViewCreated(view, savedInstanceState);
        initViews();
        initListener();
    }

    @Override
    public void initViews() {
        super.initViews();
    }

    @Override
    public void initListener() {
        super.initListener();
        setting.setmOnLSettingItemClick(new LSettingItem.OnLSettingItemClick() {
            @Override
            public void click(boolean isChecked) {
                Bundle data = new Bundle();
                startActy(SettingActivity.class, data);
            }
        });

        myApply.setmOnLSettingItemClick(new LSettingItem.OnLSettingItemClick() {
            @Override
            public void click(boolean isChecked) {
                startActy(OrderDetailActivity.class);
            }
        });

        userInfo.setmOnLSettingItemClick(new LSettingItem.OnLSettingItemClick() {
            @Override
            public void click(boolean isChecked) {
                startActy(UserInfoActivity.class);
            }
        });
    }

    @Override
    public void showMSVLoading() {

    }

    @Override
    public void showMSVEmpty() {

    }

    @Override
    public void showMSVNetErr() {

    }

    @Override
    public void showMSVUnknowErr() {

    }

    @Override
    public void showMSVContent() {

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.user_info, R.id.my_apply, R.id.setting, R.id.customer_phone, R.id.btn_login})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_login:
                startActy(LoginActivity.class);
                break;
        }
    }
}
